<template>
  <div v-loading="loading">
    <div class="top-panel">
      <TopPanel v-if="lf" :lf="lf" :parentTestBool="testBool" @catData="$_catData" @saveData="$_saveData" @test="$_test"
        @deploy="$_deploy" @debugging="debugging" :tabPosition="tabPosition"></TopPanel>
    </div>
    <div class="logic-total" v-if="!this.$route.query.leftModel">
      <div class="logic-flow-view">
        <!-- :max-percent="50" -->
        <split-pane :min-percent="15" :default-percent="percentLeft" split="vertical">
          <template slot="paneL" style="display: flex">
            <!-- 编辑自己的代码 -->
            <div class="displays">
              <div v-show="!this.$route.query.leftModel" class="left-panela">
                <LeftPanel v-if="lf" :lf="lf" :nodeList="nodeList"></LeftPanel>
              </div>

              <div class="logic-flow-view">
                <split-pane :min-percent="minPercent" :default-percent="defaultBottom" split="horizontal">
                  <template slot="paneL">
                    <div :class="[bottomPanelBool ? 'disp' : 'dispa']">
                      <div class="logic-flow-content">
                        <!-- 辅助工具栏 -->
                        <!-- v-if="ifFalse" -->
                        <Control v-show="tabPosition == 'canvas'" class="demo-control" :lf="lf"
                          :parentTestBool="testBool" @catData="$_catData" @saveData="$_saveData" @test="$_test"
                          @deploy="$_deploy" @debugging="debugging"></Control>
                        <!-- 画布 -->
                        <el-radio-group @change="getTotalData" v-model="tabPosition" class="radiogroup">
                          <!-- style="margin: 5px" -->
                          <el-radio-button size="small" label="canvas">画布展示</el-radio-button>
                          <el-radio-button size="small" label="compile">json编辑</el-radio-button>
                        </el-radio-group>
                        <div :class="[
                          'LF-view-Aa',
                          bottomPanelBool ? 'LF-view-A-B' : 'LF-view-A',
                        ]">
                          <div v-show="tabPosition == 'canvas'" :id="[
                            maximumWidthCanA
                              ? 'LF-view-scrollbar'
                              : 'LF-view',
                          ]" ref="container"></div>
                          <div v-show="tabPosition == 'compile'">
                            <JsonEditor ref="jsonEditor" @onJsonSave="onJsonSave"></JsonEditor>
                          </div>
                        </div>

                        <!-- 用户节点自定义操作面板 -->
                        <AddPanel v-if="showAddPanel" class="add-panel" :style="addPanelStyle" :lf="lf"
                          :nodeData="addClickNode" @addNodeFinish="hideAddPanel">
                        </AddPanel>
                        <!-- 属性面板 -->
                        <!-- title="设置节点属性" -->
                        <el-drawer :title="title" :visible="dialogVisible" direction="rtl" :modal="false" size="500px"
                          :before-close="closeDialog" custom-class="nodeDrawer" ref="nodeDrawer" @opened="nodeOpen"
                          :wrapperClosable="false">
                          <AmisRender :schema="schema" :data="propertyPanelData" @changeProperties="changeProperties">
                          </AmisRender>
                        </el-drawer>

                        <el-drawer title="测试" :modal="false" :visible.sync="testPanelVisible" direction="btt"
                          size="500px">
                          <AmisRender :schema="testPanelSchemaPattern" :data="testPanelData"></AmisRender>
                        </el-drawer>
                        <!-- 数据查看面板 -->
                        <el-dialog title="数据" :visible.sync="dataVisible" width="50%">
                          <DataDialog :graphData="graphData"></DataDialog>
                        </el-dialog>
                      </div>
                    </div>
                  </template>
                  <template slot="paneR">
                    <div v-show="panelModel" :class="
                      this.$route.query.leftModel
                        ? 'bottom-panel'
                        : 'bottom-panela'
                    ">
                      <!-- 111 -->
                      <BottomPanel :tabName="tabName" :onRegisterStartS="onRegisterStartS" :clearData="clearData"
                        :schema="testPanelSchemaPattern" :data="testPanelData" :tabPosition="tabPosition"
                        ref="bottomPanel" @switchPanel="switchPanel" />
                    </div>
                  </template>
                </split-pane>
              </div>
            </div>
          </template>
          <template slot="paneR">
            <!-- 编辑自己的代码 -->
            <div v-show="panelModel">
              <!-- :class="[
                this.$store.state.panel.rightPanelBool
                  ? 'right-panel'
                  : 'right-panela',
              ]" -->
              <RightPanel :schema="schema" :data="propertyPanelData" :panelVisible="dialogVisible" />
            </div>
          </template>
        </split-pane>
      </div>
    </div>
    <!-- 原本的 -->
    <div class="logic-total" v-if="this.$route.query.leftModel">
      <div v-show="!this.$route.query.leftModel" class="left-panel">
        {{ this.$route.query.leftModel }}
        <LeftPanel v-if="lf" :lf="lf" :nodeList="nodeList"></LeftPanel>
      </div>

      <div class="logic-flow-view">
        <div :class="[bottomPanelBool ? 'disp' : 'dispa']">
          <div v-show="this.$route.query.leftModel" class="left-panel">
            <LeftPanel v-if="lf" :lf="lf" :nodeList="nodeList"></LeftPanel>
          </div>
          <div class="logic-flow-content">
            <!-- 辅助工具栏 -->
            <Control class="demo-control" v-if="ifFalse" :lf="lf" :parentTestBool="testBool" @catData="$_catData"
              @saveData="$_saveData" @test="$_test" @deploy="$_deploy" @debugging="debugging"></Control>
            <!-- 节点面板 -->
            <!-- <NodePanel v-if="lf" :lf="lf" :nodeList="nodeList"></NodePanel> -->
            <!-- 画布 -->
            <div class="LF-view-A">
              <el-radio-group @change="getTotalData" v-model="tabPosition" style="margin: 5px">
                <el-radio-button size="small" label="canvas">画布展示</el-radio-button>
                <el-radio-button size="small" label="compile">json编辑</el-radio-button>
              </el-radio-group>
              <div :class="[bottomPanelBool ? 'LF-view-A-B' : 'LF-view-A']">
                <div v-show="tabPosition == 'canvas'" :id="[maximumWidthCanA ? 'LF-view-scrollbar' : 'LF-view']"
                  ref="container"></div>
                <div v-show="tabPosition == 'compile'">
                  <JsonEditor ref="jsonEditor"></JsonEditor>
                </div>
              </div>
            </div>

            <!-- 用户节点自定义操作面板 -->
            <AddPanel v-if="showAddPanel" class="add-panel" :style="addPanelStyle" :lf="lf" :nodeData="addClickNode"
              @addNodeFinish="hideAddPanel">
            </AddPanel>
            <!-- 属性面板 -->
            <!-- title="设置节点属性" -->
            <el-drawer :title="title" :visible="dialogVisible" direction="rtl" :modal="false" size="500px"
              :before-close="closeDialog" custom-class="nodeDrawer" ref="nodeDrawer" @opened="nodeOpen"
              :wrapperClosable="false">
              <AmisRender :schema="schema" :data="propertyPanelData" @changeProperties="changeProperties">
              </AmisRender>
            </el-drawer>
            <!-- 流程面板 -->
            <!-- direction="btt" -->
            <!-- <el-drawer
          title="设置流程"
          :modal="false"
          :visible.sync="processDialogVisible"
          direction="rtl"
          size="500px"
        >
          <AmisRender
            :schema="processDialogSchema"
            :data="processPanelData"
            @changeProperties="changeProperties"
          >
          </AmisRender>
        </el-drawer> -->
            <el-drawer title="测试" :modal="false" :visible.sync="testPanelVisible" direction="btt" size="500px">
              <!-- <PropertyDialog
              v-if="dialogVisible"
              :nodeData="clickNode"
              :lf="lf"
              @setPropertiesFinish="closeDialog"
            ></PropertyDialog> -->
              <AmisRender :schema="testPanelSchemaPattern" :data="testPanelData"></AmisRender>
            </el-drawer>
            <!-- 数据查看面板 -->
            <el-dialog title="数据" :visible.sync="dataVisible" width="50%">
              <DataDialog :graphData="graphData"></DataDialog>
            </el-dialog>
            <!-- <div>
            更多示例：
            <el-button type="text" @click="goto"
              >BpmnElement & TurboAdpter</el-button
            >
          </div> -->
          </div>
        </div>
        <div v-show="panelModel" :class="
          this.$route.query.leftModel ? 'bottom-panel' : 'bottom-panela'
        ">
          <BottomPanel :tabName="tabName" :onRegisterStartS="onRegisterStartS" :clearData="clearData"
            :schema="testPanelSchemaPattern" :data="testPanelData" :tabPosition="tabPosition" ref="bottomPanel"
            @switchPanel="switchPanel" />
        </div>

        <!-- <div v-show="panelModel" class="bottom-panel">
        <BottomPanel
          :schema="testPanelSchemaPattern"
          :data="testPanelData"
          ref="bottomPanel"
          @switchPanel="switchPanel"
        />
      </div> -->
      </div>
      <div v-show="panelModel" :class="[
        this.$store.state.panel.rightPanelBool
          ? 'right-panel'
          : 'right-panela',
      ]">
        <RightPanel :schema="schema" :data="propertyPanelData" :panelVisible="dialogVisible" />
      </div>
    </div>
  </div>
</template>
<script>
import LogicFlow from "@logicflow/core";
// const LogicFlow = window.LogicFlow
import {
  Menu,
  Snapshot,
  MiniMap,
  InsertNodeInPolyline,
  // DndPanel,
  SelectionSelect,
} from "@logicflow/extension";
import "@logicflow/core/dist/style/index.css";
import "@logicflow/extension/lib/style/index.css";
import "@/components/style/lf.css";
// import NodePanel from "./LFComponents/NodePanel";
import AddPanel from "./LFComponents/AddPanel";
import Control from "./LFComponents/Control";
import RightPanel from "./LFComponents/RightPanel";
import BottomPanel from "./LFComponents/BottomPanel";
import LeftPanel from "./LFComponents/LeftPanel";
import TopPanel from "./LFComponents/TopPanel";
import JsonEditor from "./LFComponents/JsonEditor";
// import PropertyDialog from './PropertySetting/PropertyDialog'
import AmisRender from "./Amis/AmisRender";
import DataDialog from "./LFComponents/DataDialog";
import { nodeList } from "./js/config.js";
import processEleSchema from "../schema/processEleSchema/index";
import { itemsStyle } from "./js/setItem.js";
import { mapMutations } from "vuex";
import {
  getSchemaById,
  updateDataById,
  deployById,
  // testDataById
} from "../services/flow";
// import 'amis/sdk/sdk'
import {
  registerStart,
  registerUser,
  registerEnd,
  registerPush,
  registerDownload,
  registerPolyline,
  registerTask,
  registerJavaClassTask,
  registerConnect,
  registerIfElse,
  registerSwitch,
} from "./registerNode";
// const demoData = require('./data.json')
const testPanelSchema = require("../schema/testPanel.json");
const processPanelSchema = require("../schema/processPanel.json");

export default {
  name: "LF",
  components: {
    // NodePanel,
    AddPanel,
    Control,
    // PropertyDialog,
    DataDialog,
    AmisRender,
    RightPanel,
    BottomPanel,
    LeftPanel,
    TopPanel,
    JsonEditor,
  },
  data() {
    return {
      tabPosition: "canvas",
      percentLeft: 80,
      defaultBottom: 100,
      minPercent: 30,
      loading: false,
      ifFalse: true,
      javaClassDebug: false, //java类断点
      tabName: "Debugging",
      maximumWidthCanA: false,
      bottomPanelBool: false,
      title: null,
      id: "",
      panelModel: true,
      // rightPanelBool: true,
      processData: {
        nodes: [],
        edges: [],
      },
      lf: null,
      showAddPanel: false,
      addPanelStyle: {
        top: 0,
        left: 0,
      },
      testBool: true,
      nodeData: null,
      addClickNode: null,
      clickNode: null,
      dialogVisible: false,
      processDialogVisible: false,
      processPanelData: {}, // 流程面板data
      propertyPanelData: null,
      graphData: null, //画布data
      processDialogSchema: null,
      testPanelSchemaPattern: {}, // 默认为对象
      testPanelVisible: false,
      testPanelData: {},
      dataVisible: false,
      config: {
        background: {
          backgroundColor: "#f7f9ff",
        },
        grid: {
          size: 10,
          visible: false,
        },
        keyboard: {
          enabled: true,
        },
        edgeTextDraggable: true,
        hoverOutline: false,
      },
      //获取节点配合，根据不同的节点变schema
      schema: {},
      moveData: {},
      nodeList,
      registerIfElseSId: null, //断点标记id
      newGraphData: null,  //最开始的画布数据
    };
  },
  watch: {
    panelBool: {
      handler(newV) {
        if (newV) {
          this.percentLeft = 75;
        } else {
          this.percentLeft = 100;
        }
      },
      deep: true,
      immediate: true,
    },
  },
  computed: {
    panelBool() {
      return this.$store.state.panel.rightPanelBool;
    },
  },
  mounted() {
    this.schema = processPanelSchema; //，进入默认展示流程面板
    // this.testPanelSchemaPattern = testPanelSchema; //，进入默认展示测试
    this.$_getProcessData();
    window.changeProperties = this.changeProperties; // 对外暴露修改流程节点属性数据的方法
    // window.changeProcessProperties = this.changeProcessProperties; // 对外暴露修改流程面板数据的方法
    this.$_getProcessPanelSchema();
  },
  methods: {
    ...mapMutations(["setRightPanelBool"]),
    $_getProcessPanelSchema() {
      this.processDialogSchema = processPanelSchema;
    },
    // json数据保存
    onJsonSave(item) {
      // 渲染画布
      this.lf.render(item);
      this.processPanelData = item.processPanelData;
      this.propertyPanelData = item.processPanelData;
      // console.log(this.$data.lf.getGraphData(), 111);
    },
    // 测试 面板折叠
    switchPanel(item) {
      this.bottomPanelBool = item;
      if (item) {
        this.defaultBottom = 60;
        this.minPercent = 40;
      } else {
        this.defaultBottom = 100;
      }
    },
    $_getProcessData() {
      // 地址栏有id属性的话，在这里添加上
      if ("id" in this.$route.query) {
        this.id = this.$route.query.id;
        this.testPanelData.id = this.id;
        this.testBool = false;
        this.getSchemaById(this.id);
        this.$_initLf();
      } else {
        alert("不存在id，无法使用");
      }
      if ("model" in this.$route.query && this.$route.query.model === "false") {
        this.panelModel = false;
      }
    },
    $_initLf() {
      var that = this;
      const lf = new LogicFlow({
        ...this.config,

        grid: {
          type: "dot", //点状
          //type: "mesh", //网格
        },
        background: {
          color: "#fff",
          opacity: 0,
        },
        plugins: [
          Menu,
          MiniMap,
          Snapshot,
          InsertNodeInPolyline,
          // DndPanel,
          SelectionSelect,
        ],
        container: this.$refs.container,
      });
      // 自定义右键菜单栏
      //  ifelse控制器自定义菜单
      lf.setMenuByType({
        type: "ifelse",
        menu: [
          {
            text: "删除",
            callback(node) {
              lf.deleteNode(node.id);
            },
          },
          {
            text: "编辑文本",
            callback(node) {
              lf.graphModel.editText(node.id);
            },
          },
          {
            text: "复制",
            callback(node) {
              lf.cloneNode(node.id);
            },
          },
          {
            text: "打断点",
            callback(node) {
              // node为该节点数据
              console.log(node.id, "打断点");
              that.$store.commit("storageBreakpoints", node);
              that.javaClassDebug = true;
              that.registerIfElseSId = node.id;
              that.getTotalDataLIst();
            },
          },
          {
            text: "取消打断点",
            callback(node) {
              // node为该节点数据
              console.log(node.id, "打断点");
              that.$store.commit("deleteBreakpoints", node);
              that.javaClassDebug = false;
              that.registerIfElseSId = node.id;
              that.getTotalDataLIst();
            },
          },
        ],
      });
      // 任务自定义菜单
      lf.setMenuByType({
        type: "task",
        menu: [
          {
            text: "删除",
            callback(node) {
              lf.deleteNode(node.id);
            },
          },
          {
            text: "编辑文本",
            callback(node) {
              lf.graphModel.editText(node.id);
            },
          },
          {
            text: "复制",
            callback(node) {
              lf.cloneNode(node.id);
            },
          },
          // {
          //   text: "打断点",
          //   callback(node) {
          //     // node为该节点数据
          //     console.log("打断点", node);
          //     that.$store.commit("storageBreakpoints", node);
          //     // that.registerIfElseSId = node.id;
          //     // that.javaClassBreakpoints = true;
          //     // that.getSchemaById();
          //   },
          // },
        ],
      });
      // java执行器
      lf.setMenuByType({
        type: "javaClassTask",
        menu: [
          {
            text: "删除",
            callback(node) {
              lf.deleteNode(node.id);
            },
          },
          {
            text: "编辑文本",
            callback(node) {
              lf.graphModel.editText(node.id);
            },
          },
          {
            text: "复制",
            callback(node) {
              lf.cloneNode(node.id);
            },
          },
          {
            text: "打断点",
            callback(node) {
              // node为该节点数据
              console.log("打断点", node);
              that.$store.commit("storageBreakpoints", node);
              that.javaClassDebug = true;
              that.registerIfElseSId = node.id;
              that.getTotalDataLIst();
            },
          },
          {
            text: "取消打断点",
            callback(node) {
              // node为该节点数据
              console.log(node.id, "打断点");
              that.$store.commit("deleteBreakpoints", node);
              that.javaClassDebug = false;
              that.registerIfElseSId = node.id;
              that.getTotalDataLIst();
            },
          },
        ],
      });
      // lf.setPatternItems();
      lf.openSelectionSelect();
      // lf.once("selection:selected", () => {
      //   lf.closeSelectionSelect();
      // });
      this.lf = lf;
      // 设置主题
      lf.setTheme(itemsStyle);
      this.$_registerNode();
    },
    // 自定义
    $_registerNode() {
      registerStart(this.lf);
      registerUser(this.lf);
      registerEnd(this.lf);
      registerPush(this.lf, this.clickPlus, this.mouseDownPlus);
      registerDownload(this.lf);
      registerPolyline(this.lf);
      registerTask(this.lf);
      registerJavaClassTask(this.lf);
      registerConnect(this.lf);
      registerIfElse(this.lf);
      registerSwitch(this.lf);
      this.$_render();
    },
    $_render() {
      this.lf.render(this.processData);
      this.$_LfEvent();
    },
    $_getData() {
      const data = this.lf.getGraphData();
      console.log(JSON.stringify(data));
    },
    $_reRenderProDialog(data) {
      this.schema = processEleSchema[data.type];
      this.propertyPanelData = this.lf.getProperties(data.id);
      if (data.text) {
        this.propertyPanelData.text = data.text.value;
      }
    },
    $_LfEvent() {
      // 点击节点
      this.lf.on("node:click", ({ data }) => {
        // console.log("点击了节点");
        console.log(data, "点击了节点");
        this.$_reRenderProDialog(data);
        this.$data.clickNode = data;
        if (!this.panelModel) {
          this.$data.dialogVisible = true;
          this.title = "设置节点";
        } else {
          this.setRightPanelBool(true);
        }
      });
      this.lf.on("edge:click", ({ data }) => {
        console.log(data, "点击了线");

        this.$data.clickNode = data;
        this.$_reRenderProDialog(data);
        if (!this.panelModel) {
          this.$data.dialogVisible = true;
        } else {
          this.setRightPanelBool(true);
        }
      });
      this.lf.on("element:click", () => {
        this.hideAddPanel();
      });
      this.lf.on("edge:add", ({ data }) => {
        console.log("edge:add", data);
      });
      this.lf.on("node:mousemove", ({ data }) => {
        // console.log("node:mousemove");
        this.moveData = data;
        if (this.moveData.x < 40 || this.moveData.x > 1100) {
          this.maximumWidthCanA = true;
        } else {
          this.maximumWidthCanA = false;
        }
      });
      //   this.lf.on("blank:click", () => {
      //     this.hideAddPanel();
      //   });
      this.lf.on("connection:not-allowed", (data) => {
        this.$message({
          type: "error",
          message: data.msg,
        });
      });
      this.lf.on("node:mousemove", () => {
        console.log("on mousemove");
      });
      this.lf.on("blank:click", ({ data }) => {
        console.log(data, 111);
        // if (!this.dialogVisible && !this.panelModel) {
        //   this.processDialogVisible = true;
        // } else {
        //   this.schema = processPanelSchema; //在panel模式的时候将右边加入流程面板
        // }
        if (!this.panelModel) {
          this.dialogVisible = true;
          // this.$_reRenderProDialog(data);
          this.schema = processPanelSchema;
          this.title = "设置流程";
        } else {
          // this.$_reRenderProDialog(data);
          this.schema = processPanelSchema;
        }
      });
    },
    clickPlus(e, attributes) {
      e.stopPropagation();
      console.log("clickPlus", e, attributes);
      const { clientX, clientY } = e;
      console.log(clientX, clientY);
      this.$data.addPanelStyle.top = clientY - 40 + "px";
      this.$data.addPanelStyle.left = clientX + "px";
      this.$data.showAddPanel = true;
      this.$data.addClickNode = attributes;
    },
    mouseDownPlus(e, attributes) {
      e.stopPropagation();
      console.log("mouseDownPlus", e, attributes);
    },
    hideAddPanel() {
      this.$data.showAddPanel = false;
      this.$data.addPanelStyle.top = 0;
      this.$data.addPanelStyle.left = 0;
      this.$data.addClickNode = null;
    },
    nodeOpen() {
      const dom =
        document.getElementsByClassName("nodeDrawer")[0].parentNode.parentNode;
      dom.style.width = "500px";
      dom.style.left = document.body.clientWidth - 500 + "px";
      console.log(screen.width, dom.style, dom, "style");
      console.log(dom);
    },
    changeProperties(data) {
      // if(data.eventType === 'submit'){
      //     return false
      // }
      if ("eventData" in data && data.eventType !== "submit") {
        if (data.eventData.id.indexOf("node") > -1) {
          this.changeNodeProperties(data);
        } else if (data.eventData.id.indexOf("panel") > -1) {
          this.changeProcessProperties(data);
        }
      }
    },
    changeNodeProperties(data) {
      const property = data.eventData.name;
      const value = data.eventData.value;
      const nodeId = this.$data.clickNode.id;
      if (property === "text") {
        //表现在在流程图上的属性
        this.lf.updateText(nodeId, value);
      } else {
        // 不显示在图上
        var obj = {};
        obj[property] = value;
        this.lf.setProperties(nodeId, obj);
      }
    },
    changeProcessProperties(data) {
      this.processPanelData[data.eventData.name] = data.eventData.value;
    },
    closeDialog() {
      this.dialogVisible = false;
    },
    closeProcessDialog() {
      this.$data.processDialogVisible = false;
    },
    $_catData() {
      this.getTotalData();
      this.$data.dataVisible = true;
    },
    // 保存
    $_saveData() {
      this.getTotalData();
      const obj = Object.assign({}, this.$data.graphData);
      obj.nodes.map((item, index) => {
        this.$data.graphData.nodes[index].properties.isStayed = false;
        this.$data.graphData.nodes[index].properties.isPassed = false;
        this.$data.graphData.nodes[index].properties.deBug = false;
      });
      console.log(obj, "object");
      if (this.id) {
        updateDataById(this.id, obj).then((res) => {
          this.$message({
            type: "success",
            message: "保存成功",
          });
          this.editKey(res);
          this.getSchemaById()
        });
      }
      //   else {
      //     const objStr = JSON.stringify(obj);
      //     const { processPanelData } = obj;
      //     saveData({
      //       ...processPanelData,
      //       schema: objStr,
      //     }).then((res) => {
      //       this.id = res.data.id;
      //       this.editKey(res);
      //       this.testBool = false;
      //       this.$message({
      //         type: "success",
      //         message: "保存成功",
      //       });
      //     });
      //   }
    },
    editKey(res) {
      this.key = res.data.key;
      this.testPanelData.key = this.key;
    },
    // 调试按钮功能
    debugging() {
      this.tabName = "Debugging";
      this.$refs.bottomPanel.bottomPanelBool = true;
      this.defaultBottom = 60;
      this.minPercent = 40;
      this.bottomPanelBool = true;
    },
    $_test() {
      console.log("点击了测试");
      if (this.$route.query.model === "false") {
        this.testPanelVisible = true;
      } else {
        this.$refs.bottomPanel.bottomPanelBool = true;
        this.bottomPanelBool = true;
        this.defaultBottom = 60;
        this.minPercent = 40;
        this.tabName = "AmisRender";
      }
      this.testPanelSchemaPattern = testPanelSchema;
      // this.testPanelVisible = true;
      //   testDataById(this.id,{}).then(res=>{
      //     console.log(res)
      //     this.$message({
      //         type: "success",
      //         message: "测试成功",
      //       });
      //   })
    },
    $_deploy() {
      deployById(this.id)
        .then((res) => {
          console.log(res, "res");
          this.$message({
            type: "success",
            message: "发布成功",
          });
        })
        .catch((error) => {
          console.log(error);
          this.$message({
            type: "error",
            message: "发布失败",
          });
        });
    },
    // 查看数据按钮的数据
    getTotalData() {
      // // 先存储一份原始数据
      this.newGraphData = this.$data.lf.getGraphData();

      this.$data.graphData = this.$data.lf.getGraphData();

      this.$data.graphData.processPanelData = this.processPanelData;
      this.$data.graphData.id = this.id;
      this.$data.graphData.maximumWidthCanA = this.maximumWidthCanA;
      this.$refs.jsonEditor.graphDatas(this.$data.graphData);
      if (this.tabPosition === "compile") {
        this.defaultBottom = 100;
        this.bottomPanelBool = false;
      }
    },

    // 打断点
    getTotalDataLIst() {
      this.getTotalData();
      //   节点加红圈
      this.$data.graphData.nodes.map((item, index) => {
        if (item.id == this.registerIfElseSId) {
          this.$data.graphData.nodes[index].properties.deBug =
            this.javaClassDebug;
        }
      });
      this.lf.render(this.$data.graphData);
    },
    async getSchemaById() {
      await getSchemaById(this.id)
        .then((res) => {
          console.log("节点数据", res);
          this.processData = res.data;
          this.maximumWidthCanA = res.data.maximumWidthCanA;
          if (
            this.processData.processPanelData !== null &&
            this.processData.processPanelData
          ) {
            this.processPanelData = this.processData.processPanelData;
            this.propertyPanelData = this.processPanelData;
          }

          this.lf.render(this.processData);
        })
        .catch((error) => {
          console.log(error, "获取schema报错");
        });
    },
    goto() {
      this.$router.push("/TurboAdpter");
    },
    // 下方调试面板中开始按钮功能
    onRegisterStartS(data) {
      this.getTotalData();

      if (data && data.activeId) {
        // 走到断点加颜色
        this.$data.graphData.nodes.map((item, index) => {
          if (item.id == data.activeId) {
            this.$data.graphData.nodes[index].properties.isStayed = true;
          } else {
            this.$data.graphData.nodes[index].properties.isStayed = false;
          }
        });
      }
      if (data && data.executionIds) {
        data.executionIds.map((item) => {
          // 走过的节点变绿色
          this.$data.graphData.nodes.map((ite, inDe) => {
            if (ite.id == item) {
              this.$data.graphData.nodes[inDe].properties.isPassed = true;
            }
          });
          // // 走过点的连线变绿色
          // this.$data.graphData.edges.map((vive, ind) => {
          //   if (vive.targetNodeId == item ) {
          //     console.log(1111, vive.targetNodeId);
          //     this.$data.graphData.edges[ind].properties.isStayed = true;
          //   }
          // });
        });
      }
      this.lf.render(this.$data.graphData);
    },
    //开启loding
    openLoading(Loading) {
      this.loading = Loading;
    },
    // 调试的清空数据
    clearData() {
      this.getTotalData();

      this.$data.graphData.nodes.map((item, index) => {
        this.$data.graphData.nodes[index].properties.isStayed = false;
        this.$data.graphData.nodes[index].properties.isPassed = false;
        // this.$data.graphData.nodes[index].properties.deBug = false;
      });
      this.lf.render(this.$data.graphData);
      // 清空断点
      // this.$store.state.storageBreakpoints.storageBreakpointsId=[];
    },
  },
};
</script>
<style lang="less" scoped>
@import "../assets/style/logicPanel.less";

.disp {
  display: flex;
  height: 67%;
}

.dispa {
  display: flex;
  height: 99.7%;
}

.displays {
  display: flex;
}

.radiogroup {
  margin: 5px 0 5px 15px;
}

::v-deep .splitter-pane.vertical.splitter-pane {
  position: absolute;
  right: 0;
  border-top: 1px solid #0000;
  box-shadow: -5px 0 10px -5px rgb(0 0 0 / 10%);
  height: calc(100vh - 63px) !important;
}

::v-deep .splitter-pane-resizer.vertical {
  // width: 11px !important;
  width: 5px !important;
  margin-left: -4px !important;
  border-left: 5px solid hsla(0, 0%, 100%, 0) !important;
  border-right: 5px solid hsla(0, 0%, 100%, 0) !important;
}

::v-deep .splitter-pane-resizer.horizontal {
  height: 2px !important;
  margin: 0px !important;
  margin-top: 5px !important;
  border-top: 1px solid hsla(0, 0%, 100%, 0) !important;
  border-bottom: 1px solid hsla(0, 0%, 100%, 0) !important;
}

::v-deep .el-radio-button__inner {
  padding: 8px 5px !important;
  width: 60px;
  font-size: 12px;
}

::v-deep .splitter-pane.vertical.splitter-paneR {
  background-color: #fff !important;
}
</style>

